import { initWXConfig } from '@/utils'
import { useEffect } from 'react'
import { history, Outlet, useLocation } from 'umi'

export default function Layout() {
  const location = useLocation()

  useEffect(() => {
    initWXConfig()
  }, [])

  if (!localStorage.token && location.pathname !== '/login') {
    history.replace('/login')
    return null
  }

  return (
    <Outlet />
  )
}
